package com.handpay.zztong.hp.ui;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;

import com.handpay.zztong.hp.log.HPLog;

/**
 * 广告banner
 * @author fplei
 *
 */
public class MyViewPager extends ViewPager {
	
	private OnReturnPositionLinsener onreturnpostion;
	private int mPostion = -1;
	
	public MyViewPager(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public MyViewPager(Context context) {
		super(context);
	}
	
	@Override
	protected void onPageScrolled(int arg0, float arg1, int arg2) {
		super.onPageScrolled(arg0, arg1, arg2);
		if(onreturnpostion!=null &&( mPostion== -1 || mPostion != arg0)){
			HPLog.i(HPLog.LFP_TAG, "POSTION="+arg0);
			mPostion = arg0;
			onreturnpostion.onposition(arg0);
		}
	}
	
	public interface OnReturnPositionLinsener{
		void onposition(int position);
	}
	public void setOnreturnpostion(OnReturnPositionLinsener onreturnpostion) {
		this.onreturnpostion = onreturnpostion;
	}
	
	
}
